<!--
 * @Descripttion: 图标选择器组件
 * @version: 2.0
 * @Author: sakuya
 * @Date: 2021年7月27日10:02:46
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-08-17 14:09:06
-->

<template>
  <el-container>
    <object
      id="ReportViewer"
      type="application/x-grplugin6-printviewer"
      width="100%"
      ref="obj"
      height="100%"
    >
      <param name="AutoRun" value="false" />
      <param name="SerialNo" :value="gr_SerialNo" />
      <param name="UserName" :value="gr_UserName" />
    </object>
  </el-container>
</template>

<script>
// require("@/utils/grhtml5-6.8-min");
import { http } from "@/utils/request";
import tool from "@/utils/tool";
export default {
  props: {},
  data() {
    return {
      gr_UserName: "报表注册一",
      gr_SerialNo:
        "FA4N5EYHM9P87Y44PKW614V44FAC64KN1F6F39W9R3J26AI7E484JU45D2984P4G60VVA83C3F3A3UA5YJUX9X8WB3KV3N5L1UJ9G4C98BSUD5E44D6BG7F5L7AB5CUVA60F398KC0F6FBIZ9B4C98332C632R665D298TWTD6EFL88ZZUB549PB6BPVX9ZT9F5LKAE63RWQ6YJHN6AMWA5SWVQ9H3JN6BIHF6KD6M39BAF3Y79F6B0H88899C9901F6EFT49LP1G59HTD6K6JA9LTRB3AG7E68YI698J898A3UA5YJUX90WNB3SAUD63WG66YZPP7KIAE6PSV68EHUB3YNVD5B5IA9TDZX6F99F6K13883EZN8FA4N5KIIM9U6TB9KC0F6FBIZ9B4C98332C632R665D298STYB63WXC3A1396AMWA5SWVQ9H3JN6BIHF6KD6M3WAAF397EG6B0H88899C9901F6EFT49LP1G58HTD6XYVQ6S58C33QXE632R665D2984P4G6EVVA849TW48TYB6MNC56",
      ReportViewer: null,
      reportdata: null,
    };
  },
  updated() {},
  mounted() {
    this.ReportViewer = this.$refs.obj;
    this.$nextTick(() => {
      this.getReport();
    });
  },

  methods: {
    async getReport() {
      this.reportdata = await tool.data.get("printReport");
      this.ReportViewer.ReportURL =
        this.reportdata.grf + "?version=" + new Date().getTime();
      this.ReportViewer.Report.ShowProgressUI = true;
      http.post(this.reportdata.url, this.reportdata.queryParams).then(res => {
        this.ReportViewer.Report.OnPrintEnd = this.OnPrintEnd;
        this.ReportViewer.Report.LoadDataFromXML(res.data);
        this.ReportViewer.Start();
      });
    },
    async OnPrintEnd() {
      await http.post(this.reportdata.endUrl).then(() => {
        window.close();
      });
    },
  },
};
</script>
<style></style>
